#!/usr/bin/python
#coding:utf-8
import socket

sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.bind(('',8001))
sock.listen(60)
con,add = sock.accept()
print "%s:%s connected!"%(add[0],add[1])
while True:
    recvs = con.recv(512)
    print recvs
    if recvs == 'break':
        print "%s:%s disconnected!"%(add[0],add[1])
        con,add = sock.accept()
        print "%s:%s connected!"%(add[0],add[1])
        continue
    sends = raw_input('>>>')
    con.send(sends)
    if sends == 'break':
        break
sock.close()

class MyServer:
    def __init__(self, ipaddr =('127.0.0.1', 8001)):
        self.ip = ipaddr



